function loadScript(src, callback) {
	let script = document.createElement('script')
	script.scr = src

	script.onload = () => callback(null, script)
	script.onerror = () => callback(new Error(`script load error: ${src}`))

	document.head.append(script)
}

// * Promisification（不改变函数本身的调用方式）
let loadScriptPromise = (src) => {
	return new Promise((resolve, reject) => {
		loadScript(src, function (error, script) {
			if (error) reject(error) // 处理错误
			else resolve(script) // 脚本加载成功
		})
	})
}

loadScriptPromise('https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.js')
	.then((script) => {})
	.catch((error) => {})
